home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP09.ZIP / CHAP09 / PATRON / ICLISITE.CPP < prev    next >
C/C++ Source or Header  |  1993-06-01  |  5KB  |  235 lines

  1. /*
  2.  * ICLISITE.CPP
  3.  *
  4.  * Implementation of the IOleClientSite interface for Patron's tenants.
  5.  *
  6.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Software Design Engineer
  9.  * Microsoft Systems Developer Relations
  10.  *
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "patron.h"
  17.  
  18.  
  19. /*
  20.  * CImpIOleClientSite::CImpIOleClientSite
  21.  * CImpIOleClientSite::~CImpIOleClientSite
  22.  *
  23.  * Parameters (Constructor):
  24.  *  pTenant         LPTENANT of the tenant we're in.
  25.  *  punkOuter       LPUNKNOWN to which we delegate.
  26.  */
  27.  
  28. CImpIOleClientSite::CImpIOleClientSite(LPTENANT pTenant, LPUNKNOWN punkOuter)
  29.     {
  30.     m_cRef=0;
  31.     m_pTen=pTenant;
  32.     m_punkOuter=punkOuter;
  33.     return;
  34.     }
  35.  
  36. CImpIOleClientSite::~CImpIOleClientSite(void)
  37.     {
  38.     return;
  39.     }
  40.  
  41.  
  42.  
  43.  
  44. /*
  45.  * CImpIOleClientSite::QueryInterface
  46.  * CImpIOleClientSite::AddRef
  47.  * CImpIOleClientSite::Release
  48.  *
  49.  * Purpose:
  50.  *  IUnknown members for CImpIOleClientSite object.
  51.  */
  52.  
  53. STDMETHODIMP CImpIOleClientSite::QueryInterface(REFIID riid, LPVOID FAR *ppv)
  54.     {
  55.     return m_punkOuter->QueryInterface(riid, ppv);
  56.     }
  57.  
  58.  
  59. STDMETHODIMP_(ULONG) CImpIOleClientSite::AddRef(void)
  60.     {
  61.     ++m_cRef;
  62.     return m_punkOuter->AddRef();
  63.     }
  64.  
  65. STDMETHODIMP_(ULONG) CImpIOleClientSite::Release(void)
  66.     {
  67.     --m_cRef;
  68.     return m_punkOuter->Release();
  69.     }
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * CImpIOleClientSite::SaveObject
  76.  *
  77.  * Purpose:
  78.  *  Requests that the container call OleSave for the object that lives
  79.  *  here.  Typically this happens on server shutdown.
  80.  *
  81.  * Parameters:
  82.  *  None
  83.  *
  84.  * Return Value:
  85.  *  HRESULT         Standard.
  86.  */
  87.  
  88. STDMETHODIMP CImpIOleClientSite::SaveObject(void)
  89.     {
  90.     //Since we're already set up with the tenant to save, this is trivial.
  91.     m_pTen->Update();
  92.     return NOERROR;
  93.     }
  94.  
  95.  
  96.  
  97.  
  98.  
  99. /*
  100.  * CImpIOleClientSite::GetMoniker
  101.  *
  102.  * Purpose:
  103.  *  Retrieves the moniker for the site in which this object lives,
  104.  *  either the moniker relative to the container or the full moniker.
  105.  *
  106.  * Parameters:
  107.  *  dwAssign        DWORD specifying that the object wants moniker
  108.  *                  assignment.  Yeah.  Right.  Got any bridges to sell?
  109.  *  dwWhich         DWORD identifying which moniker the object wants,
  110.  *                  either the container's moniker, the moniker relative
  111.  *                  to this client site, or the full moniker.
  112.  *
  113.  * Return Value:
  114.  *  HRESULT         Standard.
  115.  */
  116.  
  117. STDMETHODIMP CImpIOleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhich
  118.     , LPMONIKER FAR *ppmk)
  119.     {
  120.     *ppmk=NULL;
  121.  
  122.     /*
  123.      * We don't yet want to allow for linking to embedded objects
  124.      * within us, so we just fail for now.  If you are only a simple
  125.      * container you never have to implement this function.
  126.      */
  127.     return ResultFromScode(E_NOTIMPL);
  128.     }
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. /*
  136.  * CImpIOleClientSite::GetContainer
  137.  *
  138.  * Purpose:
  139.  *  Returns a pointer to the document's IOleContainer interface.
  140.  *
  141.  * Parameters:
  142.  *  ppContainer     LPOLECONTAINER FAR * in which to return the interface.
  143.  *
  144.  * Return Value:
  145.  *  HRESULT         Standard.
  146.  */
  147.  
  148. STDMETHODIMP CImpIOleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
  149.     {
  150.     //No implementation necessary unless you allow linking to embeddings.
  151.     *ppContainer=NULL;
  152.     return ResultFromScode(E_NOTIMPL);
  153.     }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. /*
  161.  * CImpIOleClientSite::ShowObject
  162.  *
  163.  * Purpose:
  164.  *  Tells the container to bring the object fully into view as much
  165.  *  as possible, that is, scroll the document.
  166.  *
  167.  * Parameters:
  168.  *  None
  169.  *
  170.  * Return Value:
  171.  *  HRESULT         Standard.
  172.  */
  173.  
  174. STDMETHODIMP CImpIOleClientSite::ShowObject(void)
  175.     {
  176.     /*
  177.      * We let the tenant do this, since it can access the current
  178.      * scroll position as a friend of CPages whereas we cannot.
  179.      */
  180.     m_pTen->ShowYourself();
  181.     return NOERROR;
  182.     }
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189. /*
  190.  * CImpIOleClientSite::OnShowWindow
  191.  *
  192.  * Purpose:
  193.  *  Informs the container if the object is showing itself or
  194.  *  hiding itself.  This is done only in the opening mode and allows
  195.  *  the container to know when to shade or unshade the object.
  196.  *
  197.  * Parameters:
  198.  *  fShow           BOOL indiciating that the object is being shown
  199.  *                  (TRUE) or hidden (FALSE).
  200.  * Return Value:
  201.  *  HRESULT         Standard.
  202.  */
  203.  
  204. STDMETHODIMP CImpIOleClientSite::OnShowWindow(BOOL fShow)
  205.     {
  206.     //All we have to do is tell the tenant of the open state change.
  207.     m_pTen->ShowAsOpen(fShow);
  208.     return NOERROR;
  209.     }
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216. /*
  217.  * CImpIOleClientSite::RequestNewObjectLayout
  218.  *
  219.  * Purpose:
  220.  *  Called when the object needs more room in the container and applies
  221.  *  only to extended layout negotiation not supported in OLE 2.0.
  222.  *
  223.  * Parameters:
  224.  *  None
  225.  *
  226.  * Return Value:
  227.  *  HRESULT         Standard.
  228.  */
  229.  
  230. STDMETHODIMP CImpIOleClientSite::RequestNewObjectLayout(void)
  231.     {
  232.     //Nothing to do since this is not supported in OLE 2.0.
  233.     return ResultFromScode(E_NOTIMPL);
  234.     }
  235.